#pragma warning disable 0618
using System;
using System.Collections.Generic;
using Table.DataModel;
namespace Table.Dao
{
    public class TableSceneMonsterDao:DaoBase<TableSceneMonster>
    {
        public override string GetFileName()
        {
            return "TableSceneMonster.csv";
        }
        public override void BuildIndex()
        {
            if (cacheList != null)
            {
                cachePrimaryInt = new Dictionary<int, TableSceneMonster>(cacheList.Count);
            }
            base.BuildIndex();
        }
        public override void AddPrimaryIndex(TableSceneMonster model)
        {
            #if UNITY_EDITOR
            if(cachePrimaryInt.ContainsKey(model.monsterId)) UnityEngine.Debug.LogError("数据表id重复:TableSceneMonster->id: " + model.monsterId);
            #endif
            cachePrimaryInt[model.monsterId] = model;
        }
        protected override TableSceneMonster ParseRowData(string[] rowData)
        {
            TableSceneMonster data = new TableSceneMonster();
            if (!string.IsNullOrEmpty(rowData[0]))
            {
                data.monsterId = int.Parse(rowData[0]);
            }
            if (!string.IsNullOrEmpty(rowData[1]))
            {
                data.level = int.Parse(rowData[1]);
            }
            if (!string.IsNullOrEmpty(rowData[2]))
            {
                data.modelId = int.Parse(rowData[2]);
            }
            if (!string.IsNullOrEmpty(rowData[3]))
            {
                data.name = string.Intern(rowData[3]);
            }
            if (!string.IsNullOrEmpty(rowData[4]))
            {
                data.directionX = double.Parse(rowData[4]);
            }
            if (!string.IsNullOrEmpty(rowData[5]))
            {
                data.directionZ = double.Parse(rowData[5]);
            }
            if (!string.IsNullOrEmpty(rowData[6]))
            {
                data.patrolRange = double.Parse(rowData[6]);
            }
            if (!string.IsNullOrEmpty(rowData[7]))
            {
                data.warnRange = double.Parse(rowData[7]);
            }
            if (!string.IsNullOrEmpty(rowData[8]))
            {
                data.pursueRange = double.Parse(rowData[8]);
            }
            if (!string.IsNullOrEmpty(rowData[9]))
            {
                data.friendly = int.Parse(rowData[9]);
            }
            if (!string.IsNullOrEmpty(rowData[10]))
            {
                data.enemys = rowData[10];
            }
            if (!string.IsNullOrEmpty(rowData[11]))
            {
                data.isTaskMonster = int.Parse(rowData[11]);
            }
            if (!string.IsNullOrEmpty(rowData[12]))
            {
                data.clickEvent = string.Intern(rowData[12]);
            }
            if (!string.IsNullOrEmpty(rowData[13]))
            {
                data.eventArgs = string.Intern(rowData[13]);
            }
            return data;
        }
    }
}
